#include <algorithm>
#include <iostream>

using namespace std;

string toy[35];

int main()
{
    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
        cin >> toy[i];

    for(int i = 0; i < n; i++){
        string buff;
        int d = 0;
        while(d < toy[i].size()){
            buff += toy[i][toy[i].size() - d - 1];
            d++;
        }

        toy[i] = buff;
    }//将字符串翻转过来

    sort(toy, toy + n);

    for(int i = 0; i < n; i++)
        cout << toy[i] << endl;

    return 0;
}